/**
 * Yi-Jing (I Ching) is one of the most ancient literature in Chinese history.  A more detailed
 * description of the system can be found at <a href="{@link}http://en.wikipedia.org/wiki/I_Ching>
 * Wikipedia: I Ching</a>.
 */
package divination.yijing;

import java.util.Random;

/**
 * @author Ting-Shuo Yo
 * A Yao (爻) is the fundamental unit in the Yi-Jing.  It represents either Yang 
 * (陽, an unbroken, or solid line) or Yin (陰, broken, an open line with a gap 
 * in the center).
 */
public class Yao {
    private Boolean yao = new Boolean(true);	// The Yao
    
    /**
     * Default Constructor:
     *  Set the Yao as Yang.
     */
    public Yao(){
    	this.yao = new Boolean(true);
    }
    
    public Yao(Boolean b){
    	this.yao = b;
    }

/* Access the private content */
    
    /**
     * Retrieve the Yao, o for yin and 1 for yang.
     * @return Boolean, the Yao.
     */
    public Boolean getYao(){return(this.yao);}
    /**
     * Set the Yao
     * @param b
     */
    public void setYao(Boolean b){this.yao=b;}
    
/* Renew the content of the Yao */    
    /**
     * Renew and return a new Yao with a given random seed
     * @param rd Random, a random seed to renew the Yao
     */
    public void renew(Random rd){
    	this.yao = rd.nextBoolean();
    }
    
    /**
     * Renew and return a new Yao without a given random seed
     */
    public void renew(){
    	Random rd = new Random();
    	renew(rd);
    }
        
/* String visualization of the Yao */
    public String toString(){
    	Character c2 = (yao)?'-':' ';
    	return(("-"+c2+"-"));
    }
    
}
